/**
  ******************************************************************************
  * @file    Module_Control_Func.c
  * @author  Dynapack ADT, Hsinmo
  * @version V1.0.0
  * @date    2-November-2012
  * @brief   utility Sub functions for Main program calling
  ******************************************************************************
  * @attention
  *
  * DESCRIPTION....
  *
  * <h2><center>&copy; COPYRIGHT 2012 Dynapack</center></h2>
  */
 
//==============================================================================
// Includes
//==============================================================================
#include "Driver_User_Interface.h"
#include "Global_Variable_Define.h"
#include "Vars_Bits_Define.h"
#include "Config_Info\System_Config_Info.h"
#include "Protection_Polling_Func.h"

//==============================================================================
// Global/Extern variables
//==============================================================================

//==============================================================================
// Extern functions
//==============================================================================
//==============================================================================
// Private typedef
//==============================================================================
//==============================================================================
// Private define
//==============================================================================
//==============================================================================
// Private macro
//==============================================================================
//==============================================================================
// Private Enum
//==============================================================================
//==============================================================================
// Private variables
//==============================================================================
unsigned char Breathing_Light_Repeat_Count;
unsigned char Breathing_Light_Steps;
unsigned char Num_Of_Breathing_Light_Bits;
//==============================================================================
// Private function prototypes
//==============================================================================

//==============================================================================
// Private functions
//==============================================================================
void test_pin_init(){
    GPIO_Init(TEST_PORT, TEST_PIN, GPIO_Mode_Out_PP_Low_Slow);  // set as output and PP Low level
}
void test_high(){
    TEST_PORT->ODR|=TEST_PIN;
}
void test_low(){
    TEST_PORT->ODR&=~TEST_PIN;
}
void test_toggle(){
    TEST_PORT->ODR^=TEST_PIN;
}




//void Breathing_Light_Step_For_Timer(){
//    if((G_Add_Module_Function_Status & Breathing_Light_START) == 0){
//        return;
//    }
////GPIO_HIGH(LED1_PORT, LED1_PIN);    
//    if(Breathing_Light_Steps == 0){
//        _Device_Set_Led_PWM_Enable(DeviceOn);
//        _Device_Set_Led_PWM_20_Steps(Num_Of_Breathing_Light_Bits,   Breathing_Light_Steps);  
//    }else if(Breathing_Light_Steps > 20){
//        Breathing_Light_Repeat_Count++;
//        if(Breathing_Light_Repeat_Count >= BREATHING_LIGHT_REPEAT_TIMES){
//            _Device_Set_Led_PWM_Enable(DeviceOff);
//            Num_Of_Breathing_Light_Bits = 0;
//            Breathing_Light_Repeat_Count = BREATHING_LIGHT_REPEAT_TIMES + 2;
//            Breathing_Light_Steps = 30;
//            G_Add_Module_Function_Status &= ~Breathing_Light_START;
//            G_Add_Module_Function_Status |= Breathing_Light_FINISH;
//        }else{
//            Breathing_Light_Steps = 0;
//        }
//    }else{
//        _Device_Set_Led_PWM_20_Steps(Num_Of_Breathing_Light_Bits,   Breathing_Light_Steps);  
//    }
//    Breathing_Light_Steps++;
////GPIO_LOW(LED1_PORT, LED1_PIN);    
//}
//void Display_Capacity(unsigned char capacity){
//    unsigned char NumOfLeds;
//    
//#if _LED_SETTING_NUMBERS_ == 3
//    if(capacity <= CAPACITY_DISPLAY_TH_1){
//      NumOfLeds = 1;
//    }else if(capacity <= CAPACITY_DISPLAY_TH_2){
//      NumOfLeds = 2;
//    }else{
//      NumOfLeds = 3;
//    }
//#elif _LED_SETTING_NUMBERS_ == 4    
//    if(capacity <= CAPACITY_DISPLAY_TH_1){
//        NumOfLeds = 1;
//    }else if(capacity <= CAPACITY_DISPLAY_TH_2){
//        NumOfLeds = 2;
//    }else if(capacity <= CAPACITY_DISPLAY_TH_3){
//        NumOfLeds = 3;
//    }else{
//        NumOfLeds = 4;
//    }
//#else    
//    if(capacity <= CAPACITY_DISPLAY_TH_1){
//        NumOfLeds = 1;
//    }else if(capacity <= CAPACITY_DISPLAY_TH_2){
//        NumOfLeds = 2;
//    }else if(capacity <= CAPACITY_DISPLAY_TH_3){
//        NumOfLeds = 3;
//    }else if(capacity <= CAPACITY_DISPLAY_TH_4){
//        NumOfLeds = 4;
//    }else{
//        NumOfLeds = 5;
//    }
//#endif    
//    Display_Breathing_Light(NumOfLeds);
//}
//void Display_Breathing_Light(unsigned char NumOfLeds){
//    
//    switch(NumOfLeds){
//        case DISPLAY_1_LED:
//            Num_Of_Breathing_Light_Bits = LED1_BIT;
//            break;
//        case DISPLAY_2_LED:
//            Num_Of_Breathing_Light_Bits = LED1_BIT | LED2_BIT;
//            break;
//        case DISPLAY_3_LED:
//            Num_Of_Breathing_Light_Bits = LED1_BIT | LED2_BIT | LED3_BIT;
//            break;
//        case DISPLAY_4_LED:
//            Num_Of_Breathing_Light_Bits = LED1_BIT | LED2_BIT | LED3_BIT | LED4_BIT;
//            break;
//        case DISPLAY_5_LED:
//            Num_Of_Breathing_Light_Bits = LED1_BIT | LED2_BIT | LED3_BIT | LED4_BIT | LED5_BIT;
//            break;
//        default:
//            Num_Of_Breathing_Light_Bits = 0;
//            break;
//    }
//    Breathing_Light_Steps = 0;
//    Breathing_Light_Repeat_Count = 0;
//    _Device_Set_Timer4_Interrupt_Timer_Calling_Function_With_Delay_And_Exec(0, Breathing_Light_Step_For_Timer, BREATHING_LIGHT_STEP_INTERVAL_MS);
//    G_Add_Module_Function_Status |= Breathing_Light_START;
//}
//void Finish_Display_Breathing_Light_And_Timer(){
//    _Device_Remove_Timer4_Interrupt_Timer_Calling_Function(0);
//    G_Add_Module_Function_Status &= ~Breathing_Light_START;
//    G_Add_Module_Function_Status &= ~Breathing_Light_FINISH;
//}



